<admintpl file="header" />
<link rel="stylesheet" href="__TMPL__Public/assets/css/transport.css"/>
</head>
<body>
	<div class="wrap js-check-wrap">
		<ul class="nav nav-tabs">
            <li><a href="{:U('Playbill/index')}">节目单管理</a></li>
            <li class="active"><a href="{:U('Playbill/add')}">选择素材</a></li>
            <li><a href="{:U('Playbill/customize')}">自选下发</a></li>
		</ul>
		<form action="{:U('Playbill/'.I('param.source').'_post')}" method="post" class="form-horizontal js-ajax-form" enctype="multipart/form-data">
			<if condition="I('param.source') eq 'add'" >
	            <input type="hidden"  name="name" value="{:I('param.name')}"/>
	            <input type="hidden"  name="ptype" value="{:I('param.ptype')}"/>
	            <input type="hidden"  name="template" value="{:I('param.template')}"/>
	            <input type="hidden"  name="start_at" value="{:I('param.start_at')}"/>
	            <input type="hidden"  name="end_at" value="{:I('param.end_at')}"/>
	            <input type="hidden"  name="area_id" value="{:implode(',',I('param.areas'))}"/>
	            <input type="hidden"  name="introduction" value="{:I('param.introduction')}"/>
	        </if>
	        <if condition="I('param.source') eq 'edit'" >
	            <input type="hidden"  name="pid" value="{:I('param.id')}"/>
	            <input type="hidden"  name="name" value="{:I('param.name')}"/>
	            <input type="hidden"  name="start_at" value="{:I('param.start_at')}"/>
	            <input type="hidden"  name="end_at" value="{:I('param.end_at')}"/>
	            <input type="hidden"  name="area_id" value="{:implode(',',I('param.areas'))}"/>
	            <input type="hidden"  name="introduction" value="{:I('param.introduction')}"/>
	        </if>
			<div class="row-fluid">
				<div class="span6">
					<table class="table table-bordered">
						<if condition="!is_array($template_id)" >
	                        <tr>
		                        <td>数据获取错误</td>
		                        <td>{$template_id}</td>
	                        </tr>
	                    <else />
							<for start="0" end="count($template_id)">
		                        <tr>
			                        <td width="55">区域： {$i+1}</td>
			                        <td>
			                            <foreach name="machine" item="mac">
			                            	<if condition="$mac['aid'] eq $i+1" >
				                            <div style="margin: 10px 5px;">
			                                	选择素材
			                                    <select name="dids[{$mac['aid']}][]">
				                                    <foreach name="desktop" item="vo">
				                                        <option <if condition="$mac['mid'] eq $vo['id']" >selected </if>  value="{$vo.id}">{$vo.name}</option>
				                                    </foreach>
			                                    </select>
												 播放时间
												<select name="ptimes[{$mac['aid']}][]" style="width:88px">
									                <for start="1" end="600"  name="j">
									                	<option value="{$j}" <if condition="$mac['mtime'] eq $j" >selected </if>>{$j} 秒</option>
									                </for>
								                </select>
												 权重
												<select name="pweights[{$mac['aid']}][]" style="width:88px">
									                <for start="1" end="1000" name="k">
									                	<option value="{$k}" <if condition="$mac['weights'] eq $k" >selected </if>>{$k} ‰</option>
									                </for>
								                </select>
												<a href="javascript:void(0);" onclick="delDesktop(this);" class="btn">删除</a>
				                            </div>
				                            </if>
			                            </foreach>
			                            <div>
						                    <if condition="$template_id[$i]['lockState'] neq 2" >
				                            	<a href="javascript:void(0);" onclick="addNewDesktop(this,{$i}+1);">增加素材</a>
				                            <else />
				                            	{$template_id[$i]['name']} - 锁定区域,不可编辑
											</if>
			                            	<if condition="$template_id[$i]['sources'][0]['type'] eq 'img'">
			                            		<a name="{$template_id[$i]['sources'][0]['serverPath']}" title="双击查看 - {$template_id[$i]['name']}" ondblclick="image_priview(this.name);" style="float: right;">
			                            			双击查看图例
			                            		</a>
			                            	</if>
			                            	<if condition="$template_id[$i]['sources'][0]['type'] eq 'movie'">
			                            		<a name="{$template_id[$i]['sources'][0]['serverPath']}" title="双击查看 - {$template_id[$i]['name']}" ondblclick="movie_priview(this.name);" style="float: right;">
			                            			双击查看视频
			                            		</a>
			                            	</if>
					            			<input type="hidden"  name="areas[{$i+1}][awidth]" value="{$template_id[$i]['width']}"/>
					            			<input type="hidden"  name="areas[{$i+1}][aheight]" value="{$template_id[$i]['height']}"/>
					            			<input type="hidden"  name="areas[{$i+1}][aleft]" value="{$template_id[$i]['left']}"/>
					            			<input type="hidden"  name="areas[{$i+1}][aname]" value="{$template_id[$i]['name']}"/>
					            			<input type="hidden"  name="areas[{$i+1}][atop]" value="{$template_id[$i]['top']}"/>
					            			<input type="hidden"  name="areas[{$i+1}][atype]" value="{$template_id[$i]['type']}"/>
			                            </div>
			                        </td>
		                        </tr>
							</for>
	                	</if>
					</table>
				</div>
				<div class="span6">
					<table class="table table-bordered">
	                    <php>$imgsrc = explode(',',I('param.template'));</php>
                        <tr>
	                        <td>{$imgsrc[1]}{$playbill} - 结构图</td>
                        </tr>
                        <tr>
	                        <td style="text-align: center;">
	                            <img src="{$imgsrc[2]}" alt="{$imgsrc[1]}" title="{$imgsrc[1]}"/>
	                        </td>
                        </tr>
					</table>
				</div>
			</div>
			<div class="form-actions">
				<button class="btn btn-primary js-ajax-submit" type="submit">提交</button>
        		<button type="button" class="btn" onclick="javascript:history.go(-1);">返回</button>
			</div>
		</form>
	</div>
	<script type="text/javascript" src="__PUBLIC__/js/common.js"></script>
	<script type="text/javascript" src="__PUBLIC__/js/content_addtop.js"></script>
	<script type="text/javascript">
        function delDesktop(dom){
            $(dom.parentNode).remove();
        }
        function addNewDesktop(dom,i){
            var par = $(dom.parentNode);
            var temp = '<div style="margin: 10px 5px;">\
                选择素材 <select name="dids['+i+'][]">\
                <foreach name="desktop" item="vo"><option value="{$vo.id}">{$vo.name}</option></foreach>\
                </select>\
				     播放时间 <select name="ptimes['+i+'][]" style="width:88px">\
                <for start="1" end="600" name="j"><option value="{$j}">{$j} 秒</option></for>\
                </select>\
                	权重 <select name="pweights['+i+'][]" style="width:88px">\
                <for start="1" end="1000" name="k"><option value="{$k}">{$k} ‰</option></for>\
                </select>\
                <a href="javascript:void(0);" onclick="delDesktop(this);" class="btn">删除</a>\
            </div>';
            par.before(temp);
        }
	</script>
</body>
</html>